package pack2;

public class java20 {
    public static void main(String[] arge) {
      int a1[]={0,2,5,8};
      int a2[]={0,1,2,3,4,5,6,7,8,9};
      int sum1=0;
      int sum2=0;
        for (int i = 0; i < 10; i++) {
            sum1+=search(a1,i);
        }
        for (int i = 0; i < 10; i++) {
            sum2+=search(a2,i);
        }
        System.out.println("sum1="+sum1);
        System.out.println("sum2="+sum2);
    }
    public static double search(int a[],int money){
        if(money>=a[a.length-1])
            return (a.length-1);
        for (int i = 0; i < a.length; i++) {
            if(a[i]>money)
                return (i-1);
        }
        return 0;
    }
}
